package cn.demo.app.cloud;

import cn.demo.app.a.domain.User;
import cn.demo.app.api.EchoApi;
import cn.demo.app.api.ShowApi;
import cn.ifloat.brick.basic.common.exceptions.SystemExceptionCode;
import cn.ifloat.brick.basic.common.results.R;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;

/**
 * @author: float 2022/11/2 10:14
 */

@RestController
@RequestMapping("example")
public class ExampleController {
    @Autowired
    private EchoApi echoApi;
    @Autowired
    private ShowApi showApi;

    @PostConstruct
    public void init(){
        System.out.println("init");
    }

    @RequestMapping("show")
    public void show(@RequestParam("msg") String msg){
        echoApi.echo(msg);
        System.out.println("client show:"+msg);
    }
    @RequestMapping("print")
    public void print(@RequestParam("msg") String msg){
        Map<String, String> result = showApi.print(msg);
        String rstr = showApi.str(msg);
        System.out.println("client.print :" + result + " str:" + rstr);
    }

    @PostMapping("list")
    public List<User> list(@RequestBody  User u){
        User user = new User();
        user.setId(11l);
        List<User> ss = echoApi.list(user);
        return ss;
//        return null;
    }

}
